/*
 *   Copyright 1999-2016 Asiainfo Technologies(China),Inc.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 */

package com.asiainfo.redis.service.redis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.Protocol;

import static redis.clients.jedis.Protocol.Command.CONFIG;

/**
 * @version v 1.0 on 2016/7/1 16:06
 * @auther william.xu
 */
public class MyJedis extends Jedis {

    public MyJedis() {
        super();
    }

    public MyJedis(final String host) {
        super(host);
    }

    public MyJedis(final String host, final int port) {
        super(host, port);
    }

    public MyJedis(final String host, final int port, final int timeout) {
        super(host, port, timeout);
    }

    public MyJedis(final String host, final int port, final int connectionTimeout, final int soTimeout) {
        super(host, port, connectionTimeout, soTimeout);
    }

    //jedis 2.8.1 没有实现config rewrite指令
    public void configRewrite() {
        this.client.sendCommand(CONFIG, "REWRITE");
        this.client.getStatusCodeReply();
    }

    //jedis 2.8.1 没有实现cluster failover force指令，只实现了cluster failover
    public void clusterFailoverForce() {
        checkIsInMultiOrPipeline();
        this.client.cluster(Protocol.CLUSTER_FAILOVER, "FORCE");
        this.client.getStatusCodeReply();
    }

}
